﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TVAKOLL
    {


        public TVAKOLL()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVAKOLL();
            this.DataContext = MV;
            InitializeComponent();
        }

        public override void QueryCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            dwData["VAKMANDANT"] = app.Mandant;
            dwData["VAKKOLL"] = KOLL.Trim();
            SResult = TMV.QVAK02(dwData);
            MergeData(SResult);
            base.QueryCommand(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwVAK = dwMaster;
            if (dwMaster == null)
            {
                KEY = "";
            }
            else
            {

                KEY = dwMaster["VAKKOLL"].ToString();
            }
        }
        public override void NewCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            if (!IsNew)
            {
                IsNew = true;
                return;
            }
            if (ART.Trim().Length == 0)
            {
                return;
            }
            if (KM1.Trim().Length == 0)
            {
                return;
            }
            PM["KOLL"] = ART;
            PM["KM1"] = KM1;
            TMV.NEWVAK(PM);
            ART = ""; 
            IsNew = false;
            vwMaster.View.MoveCurrentToFirst();
            base.NewCommand(sender, e);
        }
        
    }
}
